<?php
namespace Home\Model;
use Think\Model;
class VisitorModel extends Model {
    protected $vi = null;
    protected $user = null;
    //谁来看过我
    public function __construct(){
        parent::__construct();
        $this->vi = M("visitor");
        $this->user = M('user');
    }
    public function getvisitor($uid){
        $res = $this->vi->where(array('vid'=>$uid))->limit(9)->order('vtime desc')->select();
        if ($res) {
            foreach($res as $k=>$v){
                $userinfo = $this->user->find($v['uid']);
                $res[$k]['user'] = $userinfo;
            }
            return $res;
        } else {
            return array();
        }
    }

    //我去看过谁
    public function seewho($uid){
        $res = $this->vi->where(array('uid'=>$uid))->limit(9)->order('vtime desc')->select();
        if ($res) {
            foreach($res as $k=>$v){
                $userinfo = $this->user->find($v['vid']);
                $res[$k]['user'] = $userinfo;
            }
            return $res;
        } else {
            return array();
        }
    }
}